package com.epi.one.main;

import com.epi.one.basic.animal.AnimalType;
import com.epi.one.basic.animal.Cat;
import com.epi.one.basic.animal.Dog;
import com.epi.one.basic.animal.RedCat;
import com.epi.one.basic.peo.Person;
import com.epi.one.basic.peo.Stu;
import com.epi.one.basic.peo.Teacher;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.*;

/**
 * A @{code Cook} hh
 * 6
 * @see <a href="https://www.bilibili.com/"> B站 </a>
 @author dxy
 @version 1.0
 */
public class MathDemo {
    public static void main(String[] args) {
        test();
    }

    public static void test() {
        sameOne();
        constructObj();
        getDay();
        nullThrow();
        insSimple();
        arraySize();
        sealAbstract();
    }

    private static void sealAbstract() {
        Person dxy = new Teacher("dxy");
        dxy.print();
    }

    private static void arraySize() {
        int [] a={1,3,5};
        var b = new ArrayList<Integer>(100);
        System.out.println(a.length);
        System.out.println(b.size());   //0
    }

    private static void insSimple() {
        Cat cat = new RedCat("1");
        System.out.println(cat);
        if(cat instanceof RedCat cc){
            cc.setColor("green");
        }
        System.out.println(cat);
    }

    private static void nullThrow() {
        Stu s = null;
        Objects.requireNonNull(s, "你错了");
//        s.toString();
    }

    private static void getDay() {
        LocalDate now = LocalDate.now();
        DayOfWeek ofWeek = now.getDayOfWeek();
        System.out.println(ofWeek);
    }

    private static void constructObj() {
        Stu one = Stu.one();
        System.out.println(one);
        Cat cat = new Cat("小黑");
        System.out.println(cat);
        AnimalType type = AnimalType.CAT;
        System.out.println(type);  //CAT
        AnimalType animalType = AnimalType.PERSON;
        Dog dog = new Dog("1", 1, animalType);
        System.out.println(dog);
        System.out.println(animalType);

    }


    private static void sameOne() {
        Date a = new Date();
        Integer b = 300;
        System.out.println(System.identityHashCode(a));
        System.out.println(System.identityHashCode(b));
        changeDate(a, b);
        System.out.println(b);
    }

    private static void changeDate(Date date, Integer b) {
        date.setTime(0L);
        System.out.println(System.identityHashCode(date));
        System.out.println(System.identityHashCode(b));
        b = 100;
        System.out.println(System.identityHashCode(b));
    }
}
